#pragma once
class mystring
{
public:
	mystring() :mystring("") {}
	mystring(const char *);
	mystring(const mystring &);
	mystring& operator=(const mystring &);
	~mystring();

	mystring(mystring &&s) noexcept : elements(s.elements),end(s.end){
		s.elements = s.end = nullptr;
	}
	mystring& operator=(mystring &&rhs) noexcept {
		if (this != &rhs) {
			free();
			elements = rhs.elements;
			end = rhs.end;
			rhs.elements = rhs.end = nullptr;
		}
		return *this;
	}

	const char* c_str()  const { return elements; }
	size_t size() const { return end - elements; }
	size_t length() const { return end - elements; }
private:
	static allocator<char> alloc;
	char *elements;
	char *end;
	pair<char*,char*> alloc_n_copy(const char *b, const char *e);
	void range_initializer(const char *, const char *);
	void free();
};
